<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        let uage = 500;
        let sex = '男';
        let hobby = "篮球";



        let obj = {
            name: "哈哈",
            age: uage,
            // sex:sex,
            // hobby:hobby
            //属性名和变量名相同可以简写
            sex,
            hobby,
            fn1: function () {
                console.log(this, 'fn1');
            },
            fn2: function () {
                console.log(this, 'fn2');
            },
            // 函数简写 (特性不变)
            fn3() {
                console.log(this, 'fn3');
            },
            fn4() {
                console.log(this, 'fn4');
            }
        };

        console.log(obj);
        obj.fn2();
        obj.fn4();
    </script>
</body>

</html>